#ifndef QXGAME_OBJECT_H
#define QXGAME_OBJECT_H

#include <atomic>
#include "GameVector.h"
#include "GameShape.h"
#include "Facing.h"

class Object {
public:
    Object() = default;
    virtual ~Object() = default;

    virtual void OnRender() = 0;
    virtual void OnUpdate(double delta) = 0;

    virtual bool CanRemove()
    { return !isValid; };

    GameShape GetShape() const
    {
        GameShape tempShape = shape;
        if (facing == Facing::Down || facing == Facing::Up) {
            tempShape.h = shape.w;
            tempShape.w = shape.h;
        }
        return tempShape;
    }

public:
    uint32_t id = 0;
    GameShape shape;          // 物体的碰撞图形
    GameVector position;         // 物体的位置
    std::atomic<bool> isValid = true;
    Facing facing = Facing::Down;
};


#endif //QXGAME_OBJECT_H
